/*
 * Copyright (C) 2011, EADS France
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 */
package xowl.gmi.view.diagram;

import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author Laurent WOUTERS
 */
public abstract class Shape extends Widget {
    protected static final List<Couple> emptyVertices = new ArrayList<>();
    
    protected Couple minSize;
    protected boolean isFill;
    protected java.awt.Color backColor;
    protected java.awt.Color borderColor;
    protected int borderThickness;
    
    public void setBackgroundColor(java.awt.Color color) { this.backColor = color; }
    public void setBorderColor(java.awt.Color color) { this.borderColor = color; }
    public void setBorderThickness(int value) { this.borderThickness = value; }
    public void setWidth(int width) { this.minSize = new Couple(width, minSize.y); }
    public void setHeight(int height) { this.minSize = new Couple(minSize.x, height); }
    
    public Shape(int width, int height, java.awt.Color backColor, java.awt.Color borderColor, int borderThickness, boolean isFill) {
        this.minSize = new Couple(width, height);
        this.isFill = isFill;
        this.backColor = backColor;
        this.borderColor = borderColor;
        this.borderThickness = borderThickness;
    }
    
    protected boolean isVisible() { return (this.backColor != null || borderColor != null); }
    
    @Override public Couple getMinSize() { return minSize; }
    @Override public Couple getMaxSize() { return minSize; }
    @Override public Couple layout() {
        dimension = minSize;
        return minSize;
    }
    @Override public Couple layout(Couple bounds) {
        if (isFill)
            dimension = bounds;
        else
            dimension = minSize;
        return dimension;
    }
}
